<template>
    <div>
        <h1>房号增加</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>房型名称</td>
                    <td><input type="text" v-model="info.roomname" /></td>
                </tr>
                <tr>
                    <td>房号</td>
                    <td><input type="text" v-model="info.roomhao" /></td>
                </tr>
                <tr>
                    <td>排序</td>
                    <td><input type="text" v-model="info.pai" /></td>
                </tr>
                <tr>
                    <td>备注</td>
                    <td>
                        <textarea v-model="info.beizhu" role="50" sort="5"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>创建时间</td>
                    <td><input type="date" v-model="info.createTime" /></td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" v-model="info.state" name="state" value="1" />上架
                        <input type="radio" v-model="info.state" name="state" value="0" />下架
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button"  class="btn btn-success" value="增加" @click="ok"/></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { onMounted,reactive,ref } from 'vue';
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios';

const route=useRoute();
const router=useRouter();
let info=reactive({
    roomname:'',
    roomhao:'',
    pai:'',
    beizhu:'',
    createTime:'',
    state:1
})

const ok=()=>{
    axios({
        url:'/api/RoomH/Add',
        method:'post',
        data:info
    })
    .then(res=>{
        console.log(res);
        if(res.data>0){
            alert('增加成功!');
            router.push('/RoomHList');
        }
        else{
            alert('增加失败!');
        }
    })
}


</script>
